package com.zyf.pattern.prototype.deep;

import com.zyf.pattern.prototype.deep.QiTDS;

/**
 * create by yifeng
 */
public class Main {
    public static void main(String[] args) {
        QiTDS qiTDS = new QiTDS();
        try {
            QiTDS clone = (QiTDS) qiTDS.clone();
            System.out.println(qiTDS == clone);
            System.out.println(qiTDS.jgb == clone.jgb); // 浅克隆，结果返回true，该属性地址还是一样的，不可行

            // 深度克隆
            QiTDS deepClone = (QiTDS) qiTDS.deepClone();
            System.out.println(deepClone == qiTDS);
            System.out.println(qiTDS.jgb == deepClone.jgb); // 深拷贝，结果返回false
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
    }
}
